<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/WEB-INF/templates/default.xhtml">


	<ui:define name="content">
		<h1>#{IdentityModelBean.header}</h1>
		<h2>Model manager</h2>

		<h:panelGrid id="roleManagersPanel"  columns="3" border="0">

			<f:facet name="selector"></f:facet>

			<h:form id="roleForm" >
				<p:tree id="roleTree" value="#{roleManager.root}"
					selectionMode="single" var="document" dynamic="true"
					nodeSelectListener="#{roleManager.onNodeSelect}">
					<p:treeNode>
						<h:outputText value="#{document}" />
					</p:treeNode>
				</p:tree>
			</h:form>

			<f:facet name="actions"></f:facet>

			<h:form id="rmForm">
				<h:panelGrid columns="2" cellpadding="2">
					<h:panelGrid columns="1" cellpadding="2">
						<p:commandButton actionListener="#{roleManager.createNew}"
							immediate="true" image="addbutton"
							update="parentRoleName myFormPanel" />
						<p:commandButton actionListener="#{roleManager.edit}"
							immediate="true" image="editbutton"
							update="parentRoleName myFormPanel" />
					</h:panelGrid>

					<f:facet name="detail"></f:facet>

					<h:panelGroup id="myFormPanel">
						<h:panelGrid columns="3" cellpadding="2"
							rendered="#{roleManager.showForm}">
							<h:outputLabel for="#{roleManager.parentRoleName}"
								value="parentRoleName" />
							<h:outputText id="parentRoleName"
								value="#{roleManager.parentRoleName}" label="parentRoleName" />
							<h:message for="parentRoleName" errorClass="invalid" />

							<h:outputLabel for="#{roleManager.roleName}" value="roleName" />
							<h:inputText id="roleName" value="#{roleManager.roleName}"
								label="roleName" />
							<h:message for="roleName" errorClass="invalid" />

							<h:outputLabel for="#{roleManager.roleType}" value="roleType" />
							<h:selectOneMenu id="roleType" value="#{roleManager.roleType}">
								<f:selectItem itemLabel="Select One" itemValue="" />
								<f:selectItems value="#{roleManager.roleTypes}" />
							</h:selectOneMenu>
							<h:message for="roleType" errorClass="invalid" />

							<p:commandButton actionListener="#{roleManager.add}" value="add"
								update="roleForm:roleTree myFormPanel" />
						</h:panelGrid>
					</h:panelGroup>
				</h:panelGrid>

			</h:form>

		</h:panelGrid>
	</ui:define>
</ui:composition>
